using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using OpenTK.Math;

namespace raycaster
{
  public partial class Form1 : Form
  {
    public Form1()
    {
      InitializeComponent();
    }

    private Vector3 v(float x, float y, float z)
    {
      return new Vector3(x, y, z);
    }

    private void button1_Click(object sender, EventArgs e)
    {
      using (Graphics g = CreateGraphics())
      {
        Triangle tri = new Triangle(v(0, 0, 0), v(100, 0, 0), v(0, 100, 0));
        for(int x=0; x<Width; x++)
          for (int y = 0; y < Height; y++)
          {
            Ray r = new Ray(v(x, y, 100), v(0, 0, -1));
            if (tri.Intersect(r).DoesIntersect)
              g.FillRectangle(new SolidBrush(Color.Red), new Rectangle(x, y, 1, 1));
          }
      }
    }
  }
}